<!DOCTYPE html>
<html>
  <head>
    <title>订单物流管理</title>
    <include file='public/head'>
    <style>
        .layui-legend-size{font-size:14px !important;}
        .layui-nopadding{padding:0 !important;}
        .layui-overflow{overflow:auto;}
        .layui-nomargin{margin: 0 !important;}
        .layui-bottom{border-bottom:1px solid rgb(226, 226, 226);}
        .layui-input{height:30px !important; }
        .layui-form-search-item .layui-inline{margin-bottom: 5px;} 
        .layui-form-search-item label{margin-left: 15px;}
        .layui-table-page {padding: 7px 0px 0px;}
        .layui-field-padding{border-width: 1px;padding:0 0 5px 10px;}
    </style>
</head>
<body>
  <!-- layui-tab开始 -->
  <div class="layui-tab" lay-fliter="demo-tab">
    <!-- 顶部导航菜单开始 -->
    <div class="layui-tab-nav">
      <ul class="layui-tab-title">
          {:getNav('logistics','logistics_order/logisticsOrder')};
      </ul>
    </div>
    <!-- 顶部导航菜单结束 -->
    <br>
    
    <!-- 内容开始 -->
    <div class="layui-card">

        <!-- 搜索栏开始 -->
        <fieldset class="layui-elem-field layui-field-title layui-field-padding">
            <legend class="layui-legend-size">搜索框</legend>
            <form class="layui-form table-bar" action="{:cmf_plugin_url('Logistics://logistics_order/logisticsOrder')}" lay-filter="form-bar" method="post">
                <div class="layui-form-search-item">

                    <div class="layui-inline" >
                        <div class="layui-input-inline" style="width: 100px;">
                            <select name="kind" lay-verify="" class="layui-input">
                                <option value="1" <eq name="param.type" value="1">selected</eq> >订单编号</option>
                                <option value="2" <eq name="param.type" value="2">selected</eq> >物流单号</option>
                                <option value="3" <eq name="param.type" value="3">selected</eq> >手机号</option>
                            </select>
                        </div>

                        <div class="layui-input-inline" style="width: 200px;">
                            <input type="text" name="title" autocomplete="off" placeholder="请输入内容" class="layui-input" value="{$param.title}" style="width: 200px;">
                        </div>
                    </div>

                    <div class="layui-inline" style="width: 100px;">
                        <select name="type" lay-verify="" class="layui-input">
                            <option value="">选择类型</option>
                            <option value="1" <eq name="param.type" value="1">selected</eq> >线上</option>
                            <option value="2" <eq name="param.type" value="2">selected</eq> >线下</option>
                        </select>
                    </div>
                    <div class="layui-inline" style="width: 200px;">
                        <select name="code"  placeholder="选择物流公司"  lay-verify="" class="layui-select" lay-search >
                            <option value="">选择物流公司</option>
                            <volist name="logistics" id="lo">
                            <option value="{$lo.code}"  <if condition="$lo.code eq $param.code">selected="selected"</if>>{$lo.company}</option>
                            </volist>
                          </select>
                    </div>
                    <div class="layui-inline" style="width: 100px;">
                        <select name="status" lay-verify="" class="layui-input">
                            <option value="">选择状态</option>
                            <option value="1" <eq name="param.status" value="1">selected</eq> >待发货</option>
                            <option value="2" <eq name="param.status" value="2">selected</eq> >异常</option>
                            <option value="3" <eq name="param.status" value="3">selected</eq> >已发货</option>
                            <option value="4" <eq name="param.status" value="4">selected</eq> >已签收</option>
                        </select>
                    </div>



                        <label>时间</label>
                        <div class="layui-inline">
                            <div class="layui-input-inline" style="width:100px;">
                            <input type="text" class="layui-input" id="test2" name="start_time" value="{$param['start_time']}">
                            </div>
                        </div>—
                        <div class="layui-inline">
                            <div class="layui-input-inline" style="width:100px;">
                            <input type="text" class="layui-input" id="test3" name="end_time" value="{$param['end_time']}">
                            </div>
                        </div>

                    <div class="layui-inline">
                    <button type="submit" class="layui-btn layui-btn-sm layui-btn-primary " style="font-weight:800;" lay-submit="" lay-filter="demo2"><i class="layui-icon ">&#xe615;</i>搜索</button>
                    </div>
                    
                </div>
            </form>
        </fieldset>
        <!-- 搜索栏结束 -->


        <!-- 表头按钮开始 onclick="leadout()" -->
        <div class="layui-card-header layui-bg-gray layui-bottom">
<!--            <a href="{:cmf_plugin_url('Logistics://logistics_order/exmodel')}&start_time=<?php if(isset($param['start_time']) && $param['start_time']!=''){echo $param['start_time'];}?>&end_time=<?php if(isset($param['end_time']) && $param['end_time']!=''){echo $param['end_time'];}?>&status={$param['status']}&type={$param['type']}&code={$param['code']}&store_id={$param['store_id']}"  class="layui-btn layui-btn-xs" target="_blank">线下导出</a>-->
            <a href="javascript:;" class="layui-btn layui-btn-xs delivery-btn" >批量发货</a>
            <a href="javascript:;" class="layui-btn layui-btn-xs " style=" position: absolute; right: 20px;top: 10px;" onclick="library()" >快递单号库</a>
<!--            <a href="{:cmf_plugin_url('Logistics://admin_index/orderPrint')}&start_time=<?php if(isset($param['start_time']) && $param['start_time']!=''){echo $param['start_time'];}?>&end_time=<?php if(isset($param['end_time']) && $param['end_time']!=''){echo $param['end_time'];}?>&status={$param['status']}&type={$param['type']}&code={$param['code']}&store_id={$param['store_id']}"  class="layui-btn layui-btn-xs" target="_blank">线上面单打印</a>-->
        </div>
        <!-- 表头按钮结束 -->
    
    <!-- 数据表格开始 -->
    <form method="post" id="f">
    <table class="layui-table layui-nomargin">
        <thead>
            <tr>
                <th rowspan="2" style="text-align:center; width: 20px;">
                    <input type="checkbox"  id="check-box-all" >
                </th>
                <th>ID</th>
                <th>店铺ID</th>
                <th>订单编号</th>
                <th>下单时间</th>
                <th>状态</th>
                <th>类型</th>
                <th>快递公司</th>
                <th>公司编码</th>
                <th>物流单号</th>
                <th>发货时间</th>
                <th>收件人</th>
                <th>手机号</th>
                <th>收货地址</th>
                <th>操作</th>
            </tr>
            
        </thead>
        <tbody>
            <volist  name="data" id="vo">
                <tr lay-fliter="test3">
                    <th style="text-align:center;">
                        <input type="checkbox" class="check-box " name="order_num[]" value="{$vo['order_num']}">
                    </th>
                    <td>{$vo.id}</td>
                    <td>{$vo.store_id}</td>
                    <td>{$vo.order_num}</td>
                    <td>{$vo.order_time ? date('Y-m-d H:i:s',$vo.order_time) : '--'}</td>
                    <td><switch $vo.status>
                        <case 1>待发货</case>
                        <case 2>异常</case>
                        <case 3>已发货</case>
                        <case 4>已签收</case>
                        <default>--
                        </switch>
                    </td>
                    <td><switch $vo.type>
                        <case 1>线上</case>
                        <case 2>线下</case>
                        <default>--
                        </switch>
                    </td>
                    <td>{$vo.company}</td>
                    <td>{$vo.code}</td>
                    <td>{$vo.logistics_code}</td>
                    <td>{$vo.delivery_time ? date('Y-m-d H:i:s',$vo.delivery_time) : '--' }</td>
                    <td>{$vo.name}</td>
                    <td>{$vo.mobile}</td>
                    <td>{$vo.province}{$vo.city}{$vo.area}{$vo.address}</td>
                    <td>
                        <div class="layui-btn-group">
                        <button type="button" onclick="edit({$vo.id})"class="layui-btn layui-btn-primary layui-btn-xs" title="编辑"><i class="layui-icon">&#xe642;</i></button>
                        <a href="{:cmf_plugin_url('Order://admin_index/orderDetail')}?order_num={$vo.order_num}" type='button' class='layui-btn layui-btn-xs layui-btn-primary' style='font-weight:800 ;' title="查看详情"><i class="layui-icon">&#xe602;</i></a>
                        </div>
                    </td>
                </tr>
            </volist>
        </tbody>
    </table>


    <!--分页开始-->
    <div class="layui-table-page">
        <div id="layui-table-page1">
            <div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-1">
                {$page|default=''}
            </div>
        </div>
    </div>
    <!-- 分页结束 -->

    </form>
    <!-- 数据表格结束 -->
    </div>
    <!-- 内容结束 -->
    
  </div>
  <!-- layui-tab开始 -->
</body>

<include file="public/scripts"/>
<script>
  //全选/取消
  $('#check-box-all').on('click',function(){	
    console.log(1111);
    $('.check-box').prop('checked',$('#check-box-all').prop('checked'));

    console.log($('#check-box-all').prop('checked'));
  }); 


  layui.use('laydate', function(){
var laydate = layui.laydate;

//执行一个laydate实例

laydate.render({
  elem: '#test2' //指定元素
});

//年月选择器
laydate.render({
  elem: '#test3'
});

});


function configAdd(){
    if($("input[name='code']").val() == ''){
      layer.msg('请选择快递公司',{time:1200,icon:5});
      return false;
    }
    var data = $('#f').serialize();
    $.ajax({
        url:"{:cmf_plugin_url('logistics://logistics_order/deliveryInfo')}",
        type:'post',
        data:data,
        success:function(data){
            console.log(data);
            if(data.status == 'success'){
                layer.msg(data.message,{time:1200,icon:1},function(){
                    window.location.reload();
                });
            }else{
                layer.msg(data.message,{time:1200,icon:5});
            }

        },
        error:function(data){
            layer.msg('系统错误',{time:1200,icon:5});
        }
    })
}

/**
 * 配置寄件信息
 */
 function library()
{
    layer.open({
        title:'快递单号库',
        type: 2,
		shadeClose: true,//是否点击遮罩关闭
        // btn:["确定","取消"],
        area: ['1000px','850px'],
        content: "{:cmf_plugin_url('Logistics://logistics_order/library')}",
        yes:function(index,layero){
           //子页面的请求操作都放子页面
           var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
                iframeWin.tijiao();
        },btn2:function(index, layero){
			}
    })
}



/**
 * 编辑
 */
function edit(id)
{
    layer.open({
        title:'修改发货信息',
        type: 2,
		shadeClose: true,//是否点击遮罩关闭
        btn:["确定","取消"],
        area: ['1400px','300px'],
        content: "{:cmf_plugin_url('Logistics://logistics_order/ordereditPage')}?id="+id,
        yes:function(index,layero){
           //子页面的请求操作都放子页面
           var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
                iframeWin.tijiao();
        },btn2:function(index, layero){
			}
    })
}


/**
 * 发货列表
 */
 $('.delivery-btn').on('click',function (){
    var order_num = $('input[type=checkbox]:checked').map(function(){return this.value}).get().join(',');
    layer.open({
        title:'发货列表',
        type: 2,
		shadeClose: true,//是否点击遮罩关闭
        btn:["确定","取消"],
        area: ['1200px','800px'],
        content: "{:cmf_plugin_url('Logistics://logistics_order/deliveryList')}?order_num="+order_num,
        yes:function(index,layero){
          //子页面的请求操作都放子页面
          var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
            iframeWin.tijiao();
        }
    })
})


/**
*订单导出
*/   
    function leadout(){
        var data = $('#f').serialize();
        $.ajax({
            url:"{:cmf_plugin_url('Logistics://logistics/')}",
            type:'post',
            data:data,
            success:function(){},
            error:function(){}
        })
    } 


/**
 * 查看订单详细
 */
 $('.view-btn').on('click',function(){
      
        let id = $(this).data('id');
        //询问
        layer.confirm('确定要删除吗？',{icon:3,title:'提示',btn:['删除','取消']}
        ,function(index,layero){
            $.ajax({
                url:"",
                type:'post',
                data:{id:id},
                success:function(data){
                    let icon = ( data.code == 200 ) ? 1 : 5 ;
                    layer.msg( data.message , { time:1200 , icon:icon },function(){
                        window.location.reload();
                    });
                },
                error:function(data){
                    console.log(data);
                    layer.msg('系统错误',{time:1200,icon:5});
                }
            })   
        },function(index){});
       
    })



</script>
</html>